package tests;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;

import java.util.ArrayList;
import java.util.List;

import mailsystem.MailSystem;
import mailsystem.Mailbox;
import mailsystem.persistance.MailsystemPersistance;

import org.junit.Before;
import org.junit.Test;
import static org.mockito.Mockito.*;



public class MailSystemTest {
	MailSystem system;
	MailsystemPersistance persistanceMock;
	
	@Before
	public void doBefore()
	{
		persistanceMock = mock(MailsystemPersistance.class);
		List<Mailbox> boxes = new ArrayList<Mailbox>();
		boxes.add(new Mailbox(0, "", "box1", "", persistanceMock));
		when(persistanceMock.listAllMailbox()).thenReturn(boxes);
		system = new MailSystem(persistanceMock);
	}

	@Test
	public void testFindMailbox() {				
		Mailbox box = system.findMailbox("1");
		assertEquals("box1", box.getGreeting());
	}
	
	@Test
	public void testFindMailBoxDidntFind()
	{
		Mailbox box = system.findMailbox("11");
		assertNull(box);
	}
	
	@Test
	public void testBadNumberFindMailBox()
	{
		Mailbox box = system.findMailbox("11dsad");
		assertNull(box);
	}

}
